package study.springboot.starter.app.controller;

import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RList;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import study.springboot.starter.redis.template.RedisXClient;

import java.util.Map;

@Slf4j
@org.springframework.web.bind.annotation.RestController
@RequestMapping("/redis")
public class RedisController {

    @Autowired
    private RedisXClient redisXClient;
    @Autowired
    private RedissonClient redissonClient;

    public RedisController(){
        log.info(">>>>>>>>>> init RedisController");
    }

    @RequestMapping("/template")
    public Map<String, Object> template() {
        redisXClient.set("sbsb", "hahaha");
        Map<String, Object> result = Maps.newHashMap();
        return result;
    }

    @RequestMapping("/redisson")
    public Map<String, Object> redisson() {
        RList<String> dataLt = redissonClient.getList("RLIST");
        dataLt.add("wangzhj");
        Map<String, Object> result = Maps.newHashMap();
        return result;
    }
}
